<?php

namespace app\shop\controller;

// 框架基础控制类
use think\Controller;
use think\Request;

class Product extends Controller
{
    //构造函数
    public function __construct()
    {
        //手动把父类的方法获取过来
        parent::__construct();

        // check_cors_request();

        // 全局用户模型
        $this->BusinessModel = model('Business.Business');
        $this->RecordModel = model('Business.Record');
        $this->ProductModel = model('Product.Product');
        $this->CollectionModel = model('Business.Collection');
        $this->OrderProductModel = model('Product.OrderProduct');

        $year = date("Y"); //2022

        // 时间封装
        for($i=1;$i<=12;$i++)
        {
            $time = strtotime($year."-".$i);

            //获取每个月的第一天
            $start = date("Y-m-01", $time);

            $end = date('Y-m-t', $time);

            $this->TimeList[] = [strtotime($start), strtotime($end)];
        }
    }

    public function visit(){
        foreach ($this->TimeList as $item) {
            $where = [
                'createtime' => ['between', $item]
            ];

            // 已认证
            $data[] = $this->VisitModel->where($where)->count();

        }

        $this->success('', '', $data);
    }
}